package Pantallas;

import GUI.BitmapButtonField;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.TouchEvent;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;
/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class PantallaPpal extends Pantalla
{	
    /**
     * Creates a new MyScreen object
     */
    public PantallaPpal()
    {        
    	super();
            
        	Bitmap bitmap = Bitmap.getBitmapResource("x.png");
        	
            BitmapButtonField b = new BitmapButtonField(bitmap, bitmap){
            	protected boolean navigationClick(int status, int time) {
            		// TODO Auto-generated method stub
            		//UiApplication.getUiApplication().pushScreen(new PantallaPedido());
            		UiApplication.getUiApplication().pushScreen(new VentanaInicioSesion());
            		return true;
            	}
            	protected boolean touchEvent( TouchEvent event ) 
            	{
            	   switch( event.getEvent()  ) 
            	   {
            	   
            	        case TouchEvent.CLICK:
            	           //handle click event here
            	        	//UiApplication.getUiApplication().pushScreen(new PantallaPedido());
                    		UiApplication.getUiApplication().pushScreen(new VentanaInicioSesion());
            	        return true;
            	        case TouchEvent.DOWN:
            	           //handle down event here 
            	        return true;
            	        case TouchEvent.MOVE:
            	           //handle move event here
            	        return true;
            	   }
            	   return false;
            	}
            };
            
            BitmapButtonField b1 = new BitmapButtonField(bitmap, bitmap){
            	protected boolean navigationClick(int status, int time) {
            		// TODO Auto-generated method stub
            		UiApplication.getUiApplication().pushScreen(new PantallaPedido());
            		return true;
            	}
            	protected boolean touchEvent( TouchEvent event ) 
            	{
            	   switch( event.getEvent()  ) 
            	   {
            	   		
            	        case TouchEvent.CLICK:
            	           //handle click event here
            	        	UiApplication.getUiApplication().pushScreen(new PantallaStatus());
            	        return true;
            	        case TouchEvent.DOWN:
            	           //handle down event here 
            	        return true;
            	        case TouchEvent.MOVE:
            	           //handle move event here
            	        return true;
            	   }
            	   return false;
            	}
            };

            BitmapButtonField b2 = new BitmapButtonField(bitmap, bitmap){
            	protected boolean navigationClick(int status, int time) {
            		// TODO Auto-generated method stub
            		//UiApplication.getUiApplication().pushScreen(new PantallaPedido());
            		UiApplication.getUiApplication().pushScreen(new VentanaInicioSesion());
            		return true;
            	}
            	protected boolean touchEvent( TouchEvent event ) 
            	{
            	   switch( event.getEvent()  ) 
            	   {
            	   
            	        case TouchEvent.CLICK:
            	           //handle click event here
            	        	//UiApplication.getUiApplication().pushScreen(new PantallaPedido());
                    		UiApplication.getUiApplication().pushScreen(new VentanaInicioSesion());
            	        return true;
            	        case TouchEvent.DOWN:
            	           //handle down event here 
            	        return true;
            	        case TouchEvent.MOVE:
            	           //handle move event here
            	        return true;
            	   }
            	   return false;
            	}
            };
            
            BitmapButtonField b3 = new BitmapButtonField(bitmap, bitmap){
            	protected boolean navigationClick(int status, int time) {
            		// TODO Auto-generated method stub
            		UiApplication.getUiApplication().pushScreen(new PantallaPedido());
            		return true;
            	}
            	protected boolean touchEvent( TouchEvent event ) 
            	{
            	   switch( event.getEvent()  ) 
            	   {
            	   		
            	        case TouchEvent.CLICK:
            	           //handle click event here
            	        	UiApplication.getUiApplication().pushScreen(new PantallaStatus());
            	        return true;
            	        case TouchEvent.DOWN:
            	           //handle down event here 
            	        return true;
            	        case TouchEvent.MOVE:
            	           //handle move event here
            	        return true;
            	   }
            	   return false;
            	}
            };

     // Set up the 
		GridFieldManager gfm1 = new GridFieldManager(2, 2, GridFieldManager.FIXED_SIZE);
		gfm1.setColumnPadding(5);
		
			gfm1.setBorder(BorderFactory.createSimpleBorder( new XYEdges(0, 0, 0, 0),  Border.STYLE_DASHED)); 
			//add(gfm1); 
			// Size the columns of the GridFieldManager. Make sure to calculate 
			// for the padding applied to the columns. 
			int width = Display.getWidth();
			int columnWidth = (width / 2) - gfm1.getColumnPadding();
			
			int height = Display.getHeight();
			int rowHeight = (height / 2) - gfm1.getColumnPadding() - 25;
			
			for(int i = 0; i < 2; i++) {
				gfm1.setColumnProperty(i, GridFieldManager.FIXED_SIZE, columnWidth);
				gfm1.setRowProperty(i, GridFieldManager.FIXED_SIZE, rowHeight);
				} 
			// Populate the columns. 
			gfm1.add(b); 
			gfm1.add(b1); 
			gfm1.add(b2); 
			gfm1.add(b3);
     
        add(gfm1);
    }
}



	 

		


